package model;

import java.io.Serializable;
import java.util.HashMap;

/**
 * The entity of genre
 */
public class Genre extends BaseModelItem implements ModelItem, Serializable {

    public Genre() {
    }

    /**
     * Constructor for the View
     * @param name name of the genre
     */
    public Genre(String name) {
        super(name);
    }

    /**
     * Constructor for the File System
     * @param id identificator of the genre
     * @param name name of the genre
     */
    public Genre(int id, String name) {
        super(id, name);
    }
    
    public boolean equals(Object obj) {
        return ((obj instanceof Genre)  
                && (((Genre)obj).getName().equals(getName()))
                && (((Genre) obj).getVersion() == getVersion()));
    }
    
    public HashMap itemToMap() {
        HashMap map = new HashMap();
        HashMap innerMap = new HashMap();
        innerMap.put("name", parseParametr(getName()));
        map.put("genre", innerMap);
        return map;
    }
}
